#define _CRT_SECURE_NO_WARNINGS 1	
#include"Stack.h"
void StackInit(ST* ps)
{
	ps->a = (STackType*)malloc(sizeof(STackType) * 4);
	ps->capacity = 4;
	ps->top = 0;
}
void StackDestory(ST* ps)
{
	free(ps->a);
	ps->a = NULL;
	ps->capacity = ps->top = 0;
}
void StackPush(ST* ps, STackType x)
{
	if (ps->top == ps->capacity)
	{
		STackType* tmp = (STackType*)realloc(ps->a, ps->capacity * 2 * sizeof(STackType));
		ps->capacity *= 2;
	}
	ps->a[ps->top] = x;
	ps->top++;
}
void StackPop(ST* ps)
{
	if (ps->top < 0)
	{
		return;
	}
	else
	{
		ps->top--;
	}
}
int StackSize(ST* ps)
{
	return ps->top;
}
bool StackEmpty(ST* ps)
{
	return ps->top == 0;
}
STackType StackTop(ST* ps)
{
	return ps->a[ps->top - 1];
}
